<% layout('/layouts/default.html', {title: '模拟-专项考试-判断题表管理', libs: ['validate']}){ %>
<div class="main-content">
	<div class="box box-main">
		<div class="box-header with-border">
			<div class="box-title">
				<i class="fa icon-note"></i> ${text(tmockexamSpecialJudge.isNewRecord ? '新增模拟-专项考试-判断题表' : '编辑模拟-专项考试-判断题表')}
			</div>
			<div class="box-tools pull-right">
				<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
			</div>
		</div>
		<#form:form id="inputForm" model="${tmockexamSpecialJudge}" action="${ctx}/zx/mockexam/special/judge/tmockexamSpecialJudge/save" method="post" class="form-horizontal">
			<div class="box-body">
				<div class="form-unit">${text('基本信息')}</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4">${text('题目')}：</label>
							<div class="col-sm-8">
								<#form:treeselect id="parent" title="${text('题目')}"
									path="parent.id" labelPath="parent.objName"
									url="${ctx}/zx/mockexam/special/judge/tmockexamSpecialJudge/treeData?excludeCode=${tmockexamSpecialJudge.id}"
									class="" allowClear="true" readonly="true" canSelectRoot="true" canSelectParent="true"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6 hide">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required ">*</span> ${text('编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:hidden path="isNewRecord"/>
							<#form:input path="id" maxlength="50" readonly="${!tmockexamSpecialJudge.isNewRecord}" class="form-control required abc"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required  hide">*</span> ${text('岗位编码')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<#form:select path="post" items="${postList}"
									onChange="areaChanged('#objName')" readonly="true" itemLabel="postName" itemValue="postCode" blankOption="true" class="form-control select2"/>
							
							</div>
						</div>
					</div>
					
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('考试类别')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							    <#form:select path="category" onChange="areaChanged('#objName')" dictType="t_examination_category" blankOption="true" class="form-control" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6 hide">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('数据类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="objType" maxlength="10" class="form-control digits"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required">*</span> ${text('问题分数')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							    <#form:input path="score" maxlength="64" class="form-control required number"/>
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('当前层级排序号')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="treeSort" class="form-control digits"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
				  <div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required  hide">*</span> ${text('困难程度')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<#form:select path="difficulty" onChange="areaChanged('#objName')" dictType="t_degree_difficulty" blankOption="true" class="form-control" />
							</div>
						</div>
					</div>
					<div class="col-xs-6">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('知识类型')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
							<#form:select path="knowledgePointType" onChange="areaChanged('#objName')" dictType="t_knowledge_point_type" blankOption="true" class="form-control" />
							</div>
						</div>
					</div>
				</div>
				<div class="row">
				  <div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required">*</span>  ${text('问题')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:select path="objName" items="${questionList}"
									 itemLabel="objName" itemValue="id" blankOption="true" class="form-control required select2"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row hide">
					<div class="col-xs-12">
						<div class="form-group">
							<label class="control-label col-sm-2" title="">
								<span class="required hide">*</span> ${text('备注做附件的保存路径')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-10">
								<#form:textarea path="remarks" rows="4" maxlength="1555" class="form-control"/>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-xs-6 hide">
						<div class="form-group">
							<label class="control-label col-sm-4" title="">
								<span class="required hide">*</span> ${text('数据说明')}：<i class="fa icon-question hide"></i></label>
							<div class="col-sm-8">
								<#form:input path="objExplain" value="2" maxlength="10" class="form-control digits"/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="box-footer">
				<div class="row">
					<div class="col-sm-offset-2 col-sm-10">
						<% if (hasPermi('zx:mockexam:special:judge:edit')){ %>
							<button type="submit" class="btn btn-sm btn-primary" id="btnSubmit"><i class="fa fa-check"></i> ${text('保 存')}</button>&nbsp;
						<% } %>
						<button type="button" class="btn btn-sm btn-default" id="btnCancel" onclick="js.closeCurrentTabPage()"><i class="fa fa-reply-all"></i> ${text('关 闭')}</button>
					</div>
				</div>
			</div>
		</#form:form>
	</div>
</div>
<% } %>
<script>
$("#inputForm").validate({
	submitHandler: function(form){
		js.ajaxSubmitForm($(form), function(data){
			js.showMessage(data.message);
			if(data.result == Global.TRUE){
				js.closeCurrentTabPage(function(contentWindow){
					contentWindow.$('#dataGrid').dataGrid('refreshTreeChildren',
							$('#parentCode').val(), '${tmockexamSpecialJudge.id}');
				});
			}
		}, "json");
    }
});

// 选择上级节点回调方法
function treeselectCallback(id, act, index, layero){
	if (id == 'parent' && (act == 'ok' || act == 'clear')){
		// 创建并初始化下一个节点信息，如：排序号、默认值
		$.get('${ctx}/zx/mockexam/special/judge/tmockexamSpecialJudge/createNextNode?parentCode='
				+$('#parentCode').val(), function(data){
			$('#treeSort').val(data.treeSort);
		});
	}
}
function areaChanged(target){
	var post=$("#post").val();
	if(post==undefined){post="";}
		
	var category=$("#category").val();
	if(category==undefined){category="";}
	
	var difficulty=$("#difficulty").val();
	if(difficulty==undefined){difficulty="";}
	
	var knowledgePointType=$("#knowledgePointType").val();
	if(knowledgePointType==undefined){knowledgePointType="";}
	
	$.ajax({
		type:"post",
		async:true,
		url:'${ctx}/zx/question/bank/tquestionBank/findList',
		data:{
		  'objType':2,
		  'post':post,
		  'category':category,
		  'difficulty':difficulty,
		  'knowledgePointType':knowledgePointType
		},
		dataType:'json',
		success:function(msg){
			 $(target).empty();
			
			if(msg.length > 0){
				for(var i=0;i<msg.length;i++){
					var partId=msg[i].id;
					var partName=msg[i].objName;
					var option=$("<option>").attr({
						"value":partId
					}).text(partName);
					$(target).append(option);
				}
			    $(target+" option:first").prop("selected","selected");
				$(target).change();
			}
		},
		error:function(json){
			alert("操作异常");
		}
	})
}
</script>